﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using AssessmentTool.PresentationLogic.EventArguments;
using System.Collections.Generic;
using AssessmentTool.PresentationLogic.Controllers;
using AssessmentTool.Controls.HelperWindow;
using AssessmentTool.Controls;

namespace AssessmentTool.PresentationLogic
{
    public class MenuBuilder
    {
        private MenuController menu;

        
        private String actualStage;
        /* Dovrebbe essere in un file di configurazione */
        private Dictionary<String, List<MenuBuildEventArgs>> menuStages =new Dictionary<string,List<MenuBuildEventArgs>>()
        {
          {"STAGE-COMPETENZE",new List<MenuBuildEventArgs>(){
                                    new MenuBuildEventArgs(){ Text="Salva", Icon="/AssessmentTool;component/Images/saveIcon.png", Event="SAVE" ,First="YES"},
                                  //  new MenuBuildEventArgs(){ Text="Annulla", Icon="/AssessmentTool;component/Images/refresh.png", Event="REFRESH",First="NO" },
                                    new MenuBuildEventArgs(){ Text="Stampa PDF", Icon="/AssessmentTool;component/Images/documento.png", Event="EXPORTPDF",First="NO" },
                                    new MenuBuildEventArgs(){ Text="Profili", Icon="/AssessmentTool;component/Images/grafico.png", Event="GOPROFILE",First="NO" }
                                }},
           {"STAGE-PROFILI",new List<MenuBuildEventArgs>(){
                                    new MenuBuildEventArgs(){ Text="Indietro", Icon="/AssessmentTool;component/Images/back.png", Event="BACKCOMPETENZE" ,First="YES"}
                                }},
           {"ADMIN-MAIN",new List<MenuBuildEventArgs>(){
                                    
                                }},
           {"ADMIN-COMPETENZE",new List<MenuBuildEventArgs>(){
                                     new MenuBuildEventArgs(){ Text="Indietro", Icon="/AssessmentTool;component/Images/back.png", Event="BACKLISTAUTENTI" ,First="YES"},
                                   new MenuBuildEventArgs(){ Text="Salva", Icon="/AssessmentTool;component/Images/saveIcon.png", Event="SAVE" ,First="NO"},
                               //     new MenuBuildEventArgs(){ Text="Annulla", Icon="/AssessmentTool;component/Images/refresh.png", Event="REFRESH",First="NO" },
                                    new MenuBuildEventArgs(){ Text="Stampa PDF", Icon="/AssessmentTool;component/Images/documento.png", Event="EXPORTPDF",First="NO" },
                                    new MenuBuildEventArgs(){ Text="Profili", Icon="/AssessmentTool;component/Images/grafico.png", Event="GOPROFILE",First="NO" }
                                }},
            {"ADMIN-PROFILI",new List<MenuBuildEventArgs>(){
                                    new MenuBuildEventArgs(){ Text="Indietro", Icon="/AssessmentTool;component/Images/back.png", Event="BACKCOMPETENZE" ,First="YES"}
                                }}
            
        };

        private Dictionary<String, IHelper> helpers=new Dictionary<string,IHelper>() { 
        {"STAGE-COMPETENZE", new HelperAssessment(){Name="helpCompetenze"}},
        {"STAGE-PROFILI", new HelperProfile(){Name="helpProfili"}}
        };

        private static MenuBuilder _instance=null;
        
        public static MenuBuilder getInstance()
        {
            if (_instance == null)
                _instance = new MenuBuilder();
            return _instance;
        }

        private MenuBuilder()
        {
            
        }

        public void init(MenuController menu)
        {
            this.menu = menu;
        }

        public void build(String stage)
        {
            List<MenuBuildEventArgs> list = menuStages[stage];
            if(helpers.ContainsKey(stage))
                menu.setLegend(helpers[stage]);
            menu.clear();
            foreach (MenuBuildEventArgs args in list)
            {
               
                menu.addMenuItem(args);
            }
            actualStage = stage;
            
        }


    }
}
